// record the connection
let obj = {
connection: connections[i],
- name: connections[i]._name,
- uuid: connections[i]._uuid,
+ name: connections[i].get_id(),
+ uuid: connections[i].get_uuid(),
timestamp: connections[i]._timestamp,
+ item: null,
};
this._connections.push(obj);
}
},
checkConnection: function(connection) {
- let pos = this._findConnection(connection._uuid);
+ let pos = this._findConnection(connection.get_uuid());
let exists = pos != -1;
let valid = this.connectionValid(connection);
+ let similar = false;
+ if (exists) {
+ let existing = this._connections[pos];
- if (exists && !valid)
- this.removeConnection(connection);
- else if (!exists && valid)
- this.addConnection(connection);
- else if (exists && valid) {
- // propagate changes and update the UI
-
- if (this._connections[pos].timestamp != connection._timestamp) {
- this._connections[pos].timestamp = connection._timestamp;
- this._connections.sort(this._connectionSortFunction);
+ // Check if connection changed name or id
+ similar = existing.name == connection.get_id() &&
+ existing.timestamp == connection._timestamp;
+ }
- this._clearSection();
- this._queueCreateSection();
- }
+ if (exists && valid && similar) {
+ // Nothing to do
+ return;
}
+
+ if (exists)
+ this.removeConnection(connection);
+ if (valid)
+ this.addConnection(connection);
},
addConnection: function(connection) {
// record the connection
let obj = {
connection: connection,
- name: connection._name,
- uuid: connection._uuid,
+ name: connection.get_id(),
+ uuid: connection.get_uuid(),
timestamp: connection._timestamp,
+ item: null,
};
- this._connections.push(obj);
- this._connections.sort(this._connectionSortFunction);
+ Util.insertSorted(this._connections, obj, this._connectionSortFunction);
this._clearSection();
this._queueCreateSection();
},
removeConnection: function(connection) {
- if (!connection._uuid) {
- log('Cannot remove a connection without an UUID');
- return;
- }
- let pos = this._findConnection(connection._uuid);
+ let pos = this._findConnection(connection.get_uuid());
if (pos == -1) {
// this connection was never added, nothing to do here
return;
_createAutomaticConnection: function() {
let connection = new NetworkManager.Connection();
- connection._uuid = NetworkManager.utils_uuid_generate();
+ let uuid = NetworkManager.utils_uuid_generate();
connection.add_setting(new NetworkManager.SettingWired());
connection.add_setting(new NetworkManager.SettingConnection({
- uuid: connection._uuid,
+ uuid: uuid,
id: this._autoConnectionName,
type: NetworkManager.SETTING_WIRED_SETTING_NAME,
autoconnect: true
_createAutomaticConnection: function() {
let connection = new NetworkManager.Connection;
- connection._uuid = NetworkManager.utils_uuid_generate();
+ let uuid = NetworkManager.utils_uuid_generate();
connection.add_setting(new NetworkManager.SettingBluetooth);
connection.add_setting(new NetworkManager.SettingConnection({
- uuid: connection._uuid,
+ uuid: uuid,
id: this._autoConnectionName,
type: NetworkManager.SETTING_BLUETOOTH_SETTING_NAME,
autoconnect: false
},
removeConnection: function(connection) {
- if (!connection._uuid)
- return;
- let pos = this._findConnection(connection._uuid);
+ let pos = this._findConnection(connection.get_uuid());
if (pos == -1) {
// removing connection that was never added
return;
let apObj = this._networks[i];
let connections = apObj.connections;
for (let k = 0; k < connections.length; k++) {
- if (connections[k]._uuid == connection._uuid) {
+ if (connections[k].get_uuid() == connection.get_uuid()) {
// remove the connection from the access point group
connections.splice(k);
forceupdate = forceupdate || connections.length == 0;
forceupdate = true;
} else {
for (let j = 0; j < items.length; j++) {
- if (items[j]._connection._uuid == connection._uuid) {
+ if (items[j]._connection.get_uuid() == connection.get_uuid()) {
items[j].destroy();
break;
}
// record the connection
let obj = {
connection: connection,
- name: connection._name,
- uuid: connection._uuid,
+ name: connection.get_id(),
+ uuid: connection.get_uuid(),
};
this._connections.push(obj);
let connections = this._settings.list_connections();
for (let i = 0; i < connections.length; i++) {
let connection = connections[i];
- if (connection._uuid) {
+ if (connection._updatedId) {
// connection was already seen (for example because NetworkManager was restarted)
continue;
}
},
_newConnection: function(settings, connection) {
- if (connection._uuid) {
+ if (connection._updatedId) {
// connection was already seen
return;
}
devices[i].removeConnection(connection);
}
- connection._uuid = null;
connection.disconnect(connection._removedId);
connection.disconnect(connection._updatedId);
+ connection._removedId = connection._updatedId = 0;
},
_updateConnection: function(connection) {
let connectionSettings = connection.get_setting_by_name(NetworkManager.SETTING_CONNECTION_SETTING_NAME);
connection._type = connectionSettings.type;
-
connection._section = this._ctypes[connection._type] || NMConnectionCategory.INVALID;
- connection._name = connectionSettings.id;
- connection._uuid = connectionSettings.uuid;
connection._timestamp = connectionSettings.timestamp;
let section = connection._section;
- if (connection._section == NMConnectionCategory.INVALID)
+ if (section == NMConnectionCategory.INVALID)
return;
if (section == NMConnectionCategory.VPN) {
this._devices.vpn.device.checkConnection(connection);